﻿using System;
using System.Runtime.Serialization;

using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

using Ncqrs.Commands.Attributes;

using TheKitchen.Commanding.Domain;

namespace TheKitchen.Commanding.Commands
{
    [MapsToAggregateRootConstructor(typeof(Recipe))]
    [DataContract]
    public class AddNewRecipeCommand : ServicedCommand
    {
        [DataMember]
        [NotNullValidator]
        public Guid Id { get; set; }

        [DataMember]
        [NotNullValidator]
        [StringLengthValidator(0, 60)]
        public string Name { get; set; }
        
        [DataMember]
        [NotNullValidator]
        public string Description { get; set; }

        /// <summary>
        /// Validates this instance against context-free constraints.
        /// </summary>
        public override void Validate()
        {
            Validation.Validate(this);
        }
    }
}